Saving contents of richText into object

I have a richText DBE in which a user may change the contents of an object in a module.  This text may or may not have stylized text (bold, underline, etc.).  When the user clicks the OK button, I want to translate any styles into the object's text.  Right now, if I just use get dbeContents, then if the text is bold, for example, I end up with:


{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}

{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\ltrpar\b\f0\fs20 Figure FIG_54 - State Transition Diagram\par

}

within the object text when I save it and I lose the bold.

 

Chris


chrscote - Thu Feb 08 12:57:35 EST 2018

Re: Saving contents of richText into object
EHcnck - Thu Feb 08 13:09:36 EST 2018

attaching your code maybe helpful.

Re: Saving contents of richText into object
PekkaMakinen - Fri Feb 09 00:49:02 EST 2018

You have to use the "richText" function to get the rich text string to a format which can be saved to an attribute. It is not very clear from the DXL Reference, but maybe an example helps

 

Module m = current
Object o = current
string InitialText = o."Object Text"

DB MainDB = create "Rich Text Test"
DBE RichBox = richText(MainDB,"Rich text",InitialText, 200, false)

void SaveText (DBE dbe)
{
   string TextToSave = get RichBox

   // richText to save to an attribute
   o."Object Text" = richText(TextToSave)
}

DBE SaveButton = button(MainDB, "Save", SaveText)

show MainDB

Re: Saving contents of richText into object
chrscote - Mon Feb 12 08:34:39 EST 2018

PekkaMakinen - Fri Feb 09 00:49:02 EST 2018

You have to use the "richText" function to get the rich text string to a format which can be saved to an attribute. It is not very clear from the DXL Reference, but maybe an example helps

 

Module m = current
Object o = current
string InitialText = o."Object Text"

DB MainDB = create "Rich Text Test"
DBE RichBox = richText(MainDB,"Rich text",InitialText, 200, false)

void SaveText (DBE dbe)
{
   string TextToSave = get RichBox

   // richText to save to an attribute
   o."Object Text" = richText(TextToSave)
}

DBE SaveButton = button(MainDB, "Save", SaveText)

show MainDB

Thank you Pekka.  This code works great!

 

Chris